package com.ktjy.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ktjy.entity.SysRoleRight;
import com.ktjy.service.ISysRoleRightService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.stereotype.Controller;

/**
 * <p>
 *  控制器
 * </p>
 *
 * @author liuqiaomiao
 * @since 2024-03-01
 * @ClassName SysRoleRightController
 */
@Controller
@RequestMapping("/sysRoleRight")
    public class SysRoleRightController {

@Autowired
private ISysRoleRightService sysRoleRightService;

/**
* 跳转新增页面
*/
@RequestMapping(value = "/toInsert")
public Object toInsert() {
        return "/sysRoleRight/add";
        }

/**
* 增
*/
@RequestMapping(value = "/insert")
@ResponseBody
public Object insert(SysRoleRight sysRoleRight) {
        return sysRoleRightService.save(sysRoleRight);
        }

/**
* 删
*/
@RequestMapping(value = "/delete")
@ResponseBody
public Object delete(Integer id) {
        return sysRoleRightService.removeById(id);
        }

/**
* 跳转修改页面
*/
//
@RequestMapping(value = "/toUpdate")
public Object toUpdate(Integer id, Model model) {
        model.addAttribute("sysRoleRight",sysRoleRightService.getById(id));
        return "/sysRoleRight/edit";
        }

/**
* 改
*/
@RequestMapping(value = "/update")
@ResponseBody
public Object update(SysRoleRight sysRoleRight) {
        return sysRoleRightService.updateById(sysRoleRight);
        }


/**
* 分页列表
*/
@RequestMapping(value = "/page")
public Object getUserPage(Page page, SysRoleRight sysRoleRight, Model model) {
        Page pageEntity = sysRoleRightService.page(page, new QueryWrapper<>(sysRoleRight));
        model.addAttribute("sysRoleRightPage", pageEntity);
        return "/sysRoleRight/list";
        }

        }
